package mvc.config;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class FrameworkListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
        System.out.println("信息：系统已注销!");
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext context = arg0.getServletContext();
        String xmlpath = context.getInitParameter("mvc");
        String apppath = context.getRealPath("/");
        try {
			Map<String,String[]> map = ConfigFileReader.loadConfig(apppath + xmlpath);
			context.setAttribute("mvc", map);
		} catch (Exception e) {
			e.printStackTrace();
		}
        System.out.println("信息：系统已经加载完成！");
	}


}
